<template>
  <div>

  </div>
</template>

<script>
export default {
  data () {
    return { }
  },
  methods: {
    passOrFailed (i) {
      return new Promise((resolve) => {
        // 异步操作
        setTimeout(() => {
          console.log(`${i}成功`)
          resolve()
        }, 1000)
      })
    },

    test () {
      const arr = [1, 2, 3, 4, 5]
      arr.forEach(async item => {
        console.log(`${item}start`)
        await this.passOrFailed(item)
        console.log(`${item}end`)
      })
    }
  },

  mounted () {
    console.log('start!!!')
    this.test()
    console.log('end!!!')
  }
}
</script>

<style lang="less">
@import '~@/common/less/normal.less';

</style>
